package com.example.crossborderecommerce.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.crossborderecommerce.entity.Admin;
import com.example.crossborderecommerce.mapper.AdminMapper;
import com.example.crossborderecommerce.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yolanda
 * @since 2024-05-09
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {
    @Resource
    IAdminService adminService;
    @Override
    public List<Admin> findAdminByRole(String role) {
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role", role);
        queryWrapper.or(i -> {
            i.eq("role", "SUPERADMIN");
        });
        return adminService.list(queryWrapper);
    }
}
